<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
/**
 *
 * header.inc.php include file
 *
 * (c) 2011 by Mike Walsh
 *
 * @author Mike Walsh <mike@walshcrew.com>
 * @package CASL-Soccer-2011
 * @subpackage functions
 * @version $Revision$
 * @lastmodified $Author$
 * @lastmodifiedby $Date$
 *
 */

require_once('common.inc.php') ;

/**
 * casl_header_images()
 *
 * Build a customer header based on saved theme options.
 *
 */
function casl_header_images($theme_options = array())
{
    $theme_options = casl_get_theme_options() ;
?>
<div id="caslhdr" style="<?php echo $theme_options[CASL_THEME_OPTION_HDR_DIV_CSS]; ?>">

<!--  Handle the league logo image -->
<div id="caslleaguelogoimg" style="<?php echo $theme_options[CASL_THEME_OPTION_LLI_DIV_CSS]; ?>">
<?php

//  If there is a logo selected and it isn't the 'None' logo, build the logo block.
if ((!empty($theme_options[CASL_THEME_OPTION_LLI])) &&
    (ucwords($theme_options[CASL_THEME_OPTION_LLI]) != ucwords(CASL_THEME_LEAGUE_LOGO_NONE)))
{
    $url = get_stylesheet_directory_uri() ;
    $leaguelogoimg = sprintf("%s/images/CASL/%s", $url,
        sprintf(CASL_THEME_LEAGUE_LOGO_IMAGE, ucwords($theme_options[CASL_THEME_OPTION_LLI]))) ;
?>
<a href="<?php bloginfo('url'); ?>"><img src="<?php print $leaguelogoimg ; ?>" alt="<?php $alt = bloginfo('name') . ' Home' ; print $alt ;?>"></a>
<?php
}
?>
    
</div> <!--  #caslleaguelogoimg -->

<!--  Handle the left header image -->
<div id="casllfthdrimg" style="<?php echo $theme_options[CASL_THEME_OPTION_HIL_DIV_CSS]; ?>">
<?php

if (!empty($theme_options[CASL_THEME_OPTION_HIL]))
{
    $lfthdrimg = wp_get_attachment_image_src($theme_options[CASL_THEME_OPTION_HIL], 'full') ;
    
?>
<a href="<?php bloginfo('url'); ?>"><img src="<?php print $lfthdrimg[0] ; ?>" alt="<?php $alt = bloginfo('name') . ' Home' ; print $alt ;?>"></a>
<?php
}
?>
    
</div> <!--  #casllfthdrimg -->

<!--  Handle the right header image -->
<div id="caslrghthdrimg" style="<?php echo $theme_options[CASL_THEME_OPTION_HIR_DIV_CSS]; ?>">
<?php

if (!empty($theme_options[CASL_THEME_OPTION_HIR]))
{
    $rghthdrimg = wp_get_attachment_image_src($theme_options[CASL_THEME_OPTION_HIR], 'full') ;
    
?>
<a href="<?php bloginfo('url'); ?>"><img src="<?php print $rghthdrimg[0] ; ?>" alt="<?php $alt = bloginfo('name') . ' Home' ; print $alt ;?>"></a>
<?php
}
?>
    
</div> <!--  #caslrghthdrimg -->

<!--  Handle the center header image -->
<div id="caslctrhdrimg" style="<?php echo $theme_options[CASL_THEME_OPTION_HIC_DIV_CSS]; ?>">
<?php

if (!empty($theme_options[CASL_THEME_OPTION_HIC]))
{
    $ctrhdrimg = wp_get_attachment_image_src($theme_options[CASL_THEME_OPTION_HIC], 'full') ;
    
?>
<a href="<?php bloginfo('url'); ?>"><img src="<?php print $ctrhdrimg[0] ; ?>" alt="<?php $alt = bloginfo('name') . ' Home' ; print $alt ;?>" style="<?php echo $theme_options[CASL_THEME_OPTION_HIC_IMG_CSS]; ?>"></a>
<?php
}
?>
    
</div> <!--  #caslctrhdrimg -->

</div><!--  #headerimage -->
<?php
}

function casl_blogtitle()
{
    $theme_options = casl_get_theme_options() ;

?>
<h1 style="<?php echo $theme_options[CASL_THEME_OPTION_BLOG_TITLE_CSS]; ?>" id="blog-title"><span><a href="<?php home_url() ?>/" title="<?php echo esc_html( get_bloginfo('name'), 1 ) ?>" rel="home"><?php bloginfo('name') ?></a></span></h1>
<?php
}

function casl_blogdescription()
{
?>
<div style="<?php echo $theme_options[CASL_THEME_OPTION_BLOG_TAGLINE_CSS]; ?>" id="blog-description"><?php bloginfo('description') ?></div>
<?php
}

function casl_brandingopen()
{
    casl_header_images() ;
}

/**  Thematic overrides ... kind of an odd way to do it but this is how it works!  **/

function childtheme_override_brandingopen() {
    $theme_options = get_option('casl_theme_options') ;
?>
<div id="branding" style="<?php echo $theme_options[CASL_THEME_OPTION_BRANDING_DIV_CSS]; ?>">
<?php
    casl_header_images($theme_options) ;
}

function childtheme_override_brandingclose() { ?>
</div><!-- #branding -->
<?php }

function childtheme_override_blogtitle() {
    casl_blogtitle() ;
}

function childtheme_override_blogdescription() {
    casl_blogdescription() ;
}
?>
